package may.test_5_29;

import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        scanner.nextLine();
        String str = scanner.nextLine();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if(str.charAt(i) != 'M' && str.charAt(i) != 'T') {
                count++;
            }
        }
        n = n - count;
        System.out.println(n + Math.min(k,count));
    }
}
